var Widget = function(){
  this.init();
};
Widget.prototype = {
  params: {
    passport: ''
  },
  init: function(){
    this.initParams();
    this.initEvent();
  },
  initParams: function(){
     this.params.passport = Pub.getCookie('_PASSPORT');
      var lcHref = window.location.href;
      if (lcHref.indexOf('help-issue') == -1) {
          Pub.setSession('isEdit',0);
      }

  },
  userInfoData: function(){
    var _this = this;
    var paramsObj = {
      passport: _this.params.passport
    };
    Api.accountinformation(paramsObj, function(data){
      if(data.headPortrait){
        $('#account_avatar').css('display','inline-block');
        $('#account_avatar').attr('src', data.headPortrait);
        $('.header-avatar').hide();
      }else{
        $('.header-avatar').css('display', 'inline-block');
        $('#account_avatar').hide();
      }
      $('#account').text(data.adminName || '-');
      $('#section').text(data.department || '-');
      $('#login_time').text(data. gmt || '-');
      $('#login_area').text(data.province + data.city + '('+data.ip+')' || '-');
      $('#last_login_time').text(data.gmtGheLast || '-');
    });
  },
  messageGet: function(){
    var _this = this;
    var paramsObj = {
        passport: _this.params.passport
    };
    Api.homePage(paramsObj, function(data){
        var data=data.list;
        $('#message_total').text(parseInt(data.hasBeenShipped)+parseInt(data.newCompleteOrder));
        $('#hasBeenNum').text(data.hasBeenShipped);
        $('#newCompleteOrderNum').text(data.newCompleteOrder);
    });
  },
  clickEvent: function(){
    var _this = this;
    $('#logout').on('click', function(){
      layui.use('layer', function(){
          layer.confirm('您确定要退出登录吗？', {
            btn: ['确定','取消'] //按钮
          }, function(){
            Pub.setCookie('_PASSPORT', null);
            window.location.href = Pub.getHtmlUrl('login.html');
          }, function(){

          });
      });

    });
  },
  initEvent: function(){
    var _this = this;
    _this.clickEvent();
    //_this.userInfoData();
    // _this.messageGet();
  }
};
var widget = new Widget();